package br.com.wepa.webapps.orca.logica.persistencia.search;

import java.util.HashMap;

import br.com.wepa.webapps.search.Search;
import br.com.wepa.webapps.search.SimpleSearcher;

public class Searcher extends SimpleSearcher implements Cloneable {

	public Searcher() {
		setMap(new HashMap<String, Search>());
	}

	public Searcher(String defaultSearchName) {
		super(defaultSearchName);
	}

	/**
	 * Cria um search para este bean e adiciona no buscador
	 * @param searchName
	 * @param exampleInstance
	 * @param excludeProperty
	 */
	@SuppressWarnings("unchecked")
	public void addSearchBean(String searchName, Object exampleInstance,
			String... excludeProperty) {
		addSearch(searchName, new BeanSearch(exampleInstance, excludeProperty));
	}

	/**
	 * Cria uma named query de busca e adiciona no buscador
	 * @param searchName
	 * @param queryName
	 * @param params
	 */
	public void addSearchNamedQuery(String searchName, String queryName,
			Object... params) {
		addSearch(searchName, new NamedQuerySearch(queryName, params));
	}

}
